<template>
    <div class="jobcommon EditResumeInfo" v-if="JSON.stringify(resume_info) != '{}'">
        <div class="smalbox">
            <div class="backnavjob">
                <h1 @click="closejibenxinxi('close')">
                    <img
                        data-v-61dd7a3d=""
                        src="../../assets//newimg/index/icon_right_h.png"
                        alt=""
                    />
                </h1>
                <h2>
                    <span>简历-求职意向</span>
                </h2>
                <h3></h3>
            </div>

            <div class="imSelectParent" @click="zhuangtaiKey = !zhuangtaiKey">
                <div class="list_height plist-txt imitateSelect">
                    <div class="pic"></div>
                    <div class="tit font14">
                        目前状态<span class="font_red_light">*</span>
                    </div>
                    <div class="describe font13">
                        <span class="selectTxt">{{
                            resume_info.current_cn
                        }}</span>
                    </div>
                    <div class="arrow"></div>
                    <div class="clear"></div>
                </div>
            </div>
            <div class="imSelectParent">
                <div
                    class="list_height plist-txt imitateSelect"
                    @click="gzxingzhiKey = !gzxingzhiKey"
                >
                    <div class="pic"></div>
                    <div class="tit font14">
                        工作性质<span class="font_red_light">*</span>
                    </div>
                    <div class="describe font13">
                        <span class="selectTxt">{{
                            resume_info.nature_cn
                        }}</span>
                    </div>
                    <div class="arrow"></div>
                    <div class="clear"></div>
                </div>
            </div>
            <div
                class="list_height plist-txt qs-relative js-actionParent"
                @click="hangyeKey = !hangyeKey"
            >
                <div class="abAct js-showActionSheet"></div>
                <div class="pic"></div>
                <div class="tit font14">期望行业</div>
                <div class="describe font13 qs-temp-level1">
                    <span class="qs-temp-txt-trade">{{
                        resume_info.trade_cn
                    }}</span>
                </div>
                <div class="arrow"></div>
                <div class="clear"></div>
            </div>
            <div
                class="list_height plist-txt qs-relative js-actionParent"
                @click="CascaderKey = !CascaderKey"
            >
                <div class="abAct js-showActionSheet"></div>
                <div class="pic"></div>
                <div class="tit font14">
                    期望职位<span class="font_red_light">*</span>
                </div>
                <div class="describe font13 qs-temp">
                    <span class="qs-temp-txt-jobs">{{
                        resume_info.intention_jobs
                    }}</span>
                </div>
                <div class="arrow"></div>
                <div class="clear"></div>
            </div>
            <div class="imSelectParent" @click="xinziKey = !xinziKey">
                <div class="list_height plist-txt imitateSelect">
                    <div class="pic"></div>
                    <div class="tit font14">
                        期望薪资<span class="font_red_light">*</span>
                    </div>
                    <div class="describe font13">
                        <span class="selectTxt">{{ resume_info.wage_cn }}</span>
                    </div>
                    <div class="arrow"></div>
                    <div class="clear"></div>
                </div>
            </div>
            <div
                class="list_height plist-txt qs-relative js-actionParent"
                @click="addressKey = !addressKey"
            >
                <div class="abAct js-showActionSheet"></div>
                <div class="pic"></div>
                <div class="tit font14">
                    工作地区<span class="font_red_light">*</span>
                </div>
                <div class="describe font13 qs-temp-new-city">
                    <span class="qs-temp-txt-city" data-otxt="请选择">{{
                        resume_info.district_cn
                    }}</span>
                </div>
                <div class="arrow"></div>
                <div class="clear"></div>
            </div>

            <div class="j_newbutton">
                <div class="j_newbtn" @click="closejibenxinxi()">保存</div>
            </div>

            <!-- 目前状态 -->
            <van-action-sheet
                v-model="zhuangtaiKey"
                :actions="zhuangtaiKeyactions"
                @select="zhuangtaionSelect"
                :duration="0.2"
            />

            <!-- 工作性质 -->
            <van-action-sheet
                v-model="gzxingzhiKey"
                :actions="gzxingzhiKeyactions"
                @select="gzxingzhiSelect"
                :duration="0.2"
            />

            <!-- 期望薪资 -->
            <van-action-sheet
                v-model="xinziKey"
                :actions="xinziKeyactions"
                @select="xinziSelect"
                :duration="0.2"
            />

            <van-popup
                v-model="hangyeKey"
                position="bottom"
                :style="{ height: '60%' }"
            >
                <Cascader
                    v-if="hangyeKey"
                    :jobs="guidance.trade"
                    :title="'请选择行业'"
                    :num="3"
                    :leavl="1"
                    @calcaCallback="calcaCallbackHangye"
                />
            </van-popup>

            <van-popup
                v-model="CascaderKey"
                position="bottom"
                :style="{ height: '60%' }"
            >
                <Cascader
                    v-if="CascaderKey"
                    :jobs="guidance.jobs"
                    :title="'请选择职位'"
                    :num="5"
                    :leavl="3"
                    @calcaCallback="calcaCallbackzhiye"
                />
            </van-popup>

            <van-popup
                v-model="addressKey"
                position="bottom"
                :style="{ height: '60%' }"
            >
                <Cascader
                    v-if="addressKey"
                    :jobs="guidance.city"
                    :title="'请选择地区'"
                    :num="3"
                    :leavl="3"
                    @calcaCallback="calcaCallbacaddres"
                />
            </van-popup>
            <div class="zhanwei"></div>
        </div>
    </div>
</template>

<script>
import { axiosPost } from '../../axios';
import { Toast } from 'vant';
import Cascader from '../Cascader';
export default {
    name: '',
    components: { Cascader },
    props: ['guidance', 'resume_info'],
    data() {
        return {
            // 目前状态
            zhuangtaiKeyactions: [],
            zhuangtaiKey: false,

            // 工作性质
            gzxingzhiKeyactions: [],
            gzxingzhiKey: false,

            // 期望薪资
            xinziKeyactions: [],
            xinziKey: false,

            // 选择行业
            hangyeKey: false,

            // 选择职位
            CascaderKey: false,

            // 选择工作地区
            addressKey: false,
        };
    },
    computed: {},
    mounted() {
        // console.log(this.resume_info);
        // console.log(this.guidance);
        // current
        // 修改目前状态数据
        let current = [];
        for (let i in this.guidance.current) {
            current.push({
                name: this.guidance.current[i],
                id: i,
            });
        }
        this.zhuangtaiKeyactions = current;

        // 修改行业数据
        this.guidance.trade = [this.guidance.trade];

        // 修改工作性质数据
        let jobs_nature = [];
        for (let i in this.guidance.jobs_nature) {
            jobs_nature.push({
                name: this.guidance.jobs_nature[i],
                id: i,
            });
        }
        this.gzxingzhiKeyactions = jobs_nature;

        // 修改期望薪资
        let wage = [];
        for (let i in this.guidance.wage) {
            wage.push({
                name: this.guidance.wage[i],
                id: i,
            });
        }
        this.xinziKeyactions = wage;
    },
    methods: {
        closejibenxinxi(type) {
            if (type) {
                this.$emit('closeProps', { type: 1, key: false });
                return;
            }
            // this.$emit('closeProps', { type: 1, key: false });
            if (!this.resume_info.current_cn) {
                return Toast({
                    message: '请选择状态',
                    duration: 2000,
                });
            }
            if (!this.resume_info.nature_cn) {
                return Toast({
                    message: '请选择工作性质',
                    duration: 2000,
                });
            }
            if (!this.resume_info.intention_jobs) {
                return Toast({
                    message: '请选择期望职位',
                    duration: 2000,
                });
            }
            if (!this.resume_info.wage_cn) {
                return Toast({
                    message: '请选择期望薪资',
                    duration: 2000,
                });
            }
            // console.log(JSON.parse(JSON.stringify(this.resume_info)));
            this.resume_info.pid = this.resume_info.id;
            axiosPost('/apis/resume/edit_intent', this.resume_info, (res) => {
                Toast({
                    message: res.msg,
                    duration: 2000,
                });
                if (res.status != 1) {
                    return;
                }
                this.$emit('closeProps', { type: 1, key: true });
            });
        },
        // 目前状态回调
        zhuangtaionSelect(item) {
            this.zhuangtaiKey = false;
            this.resume_info.current_cn = item.name;
            this.resume_info.current = item.id;
        },
        // 工作性质回调
        gzxingzhiSelect(item) {
            this.gzxingzhiKey = false;
            this.resume_info.nature = item.id;
            this.resume_info.nature_cn = item.name;
        },
        // 期望行业回调
        calcaCallbackHangye(data) {
            this.hangyeKey = false;
            this.resume_info.trade_cn = data
                .map((option) => option.name)
                .join(',');
            this.resume_info.trade = data.map((option) => option.id).join(',');
        },
        // 期望职位
        calcaCallbackzhiye(data) {
            this.CascaderKey = false;
            this.resume_info.intention_jobs_id = data
                .map((option) => option.id)
                .join(',');
            this.resume_info.intention_jobs = data
                .map((option) => option.name)
                .join(',');
        },
        // 期望薪资回调
        xinziSelect(item) {
            this.xinziKey = false;
            this.resume_info.wage = item.id;
            this.resume_info.wage_cn = item.name;
        },
        // 地区选择回调
        calcaCallbacaddres(data) {
            this.addressKey = false;
            this.resume_info.district = data
                .map((option) => option.id)
                .join(',');
            this.resume_info.district_cn = data
                .map((option) => option.name)
                .join(',');
        },
    },
};
</script>
<style lang="less" src="../../assets/css/jobCommon.less" scope></style>
<style lang="css" src="../../assets/css/van-action-sheet.css" scope></style>

<style lang="less" scope></style>
